<template>
	<view class="exchangeOrder-q">
		<view class="exchangeOrder-w">
			<view class="exchangeOrder-e">
				<view class="exchangeOrder-r">
					<view class="exchangeOrder-t"><image src="../../../static/img/ding.png" mode=""></image></view>
					<view class="exchangeOrder-y">
						<view class="exchangeOrder-u">{{ addressList.province }}{{ addressList.city }}{{ addressList.district }}{{ addressList.detail }}</view>
						<view class="exchangeOrder-i">{{ addressList.realName }} {{ addressList.phone }}</view>
					</view>
				</view>
				<view class="exchangeOrder-o"><image src="../../../static/img/fang.png" mode=""></image></view>
			</view>
		</view>
		<view class="exchangeOrder-p"><text>共3件商品</text></view>
		<view class="exchangeOrder-a">
			<view class="exchangeOrder-s">
				<view class="exchangeOrder-d" v-for="(item, index) in orderList" :key="index">
					<view class="exchangeOrder-f">
						<view class="exchangeOrder-g"><image :src="item.image" mode=""></image></view>
						<view class="exchangeOrder-h">
							<view class="exchangeOrder-j">{{ item.storeName }}</view>
							<view class="exchangeOrder-k">兑换券套餐</view>
							<view class="exchangeOrder-l">{{ item.price }}豆</view>
						</view>
					</view>
					<view class="exchangeOrder-z">×1</view>
				</view>
			</view>
			<view class="exchangeOrder-x">
				<view class="exchangeOrder-c">配送服务</view>
				<view class="exchangeOrder-v">快递 免邮</view>
			</view>
		</view>
		<view class="exchangeOrder-b"><view class="exchangeOrder-n" @click="getVouchersAdd">立即兑换</view></view>
	</view>
</template>

<script>
import { getVouchersGoods, getAddressList,getVouchersAdd } from '@/api/order';
export default {
	data() {
		return {
			couponId: 0,
			orderList: [],
			addressList: '',
			id:0
		};
	},
	created: function() {
		// this.couponId = this.$yroute.query.id;
	},
	mounted() {
		let that = this;
		
		console.log('11111111',uni.getStorageSync('item'))
		that.couponId = parseInt(uni.getStorageSync('item').cid);
		that.id =  uni.getStorageSync('item').id;
		that.gettesefun(that.couponId);
		that.getAddressList();
	},
	methods: {
		gettesefun(couponId) {
			getVouchersGoods(parseInt(couponId)).then(res => {
				if (res.status == 200) {
					this.orderList = res.data;
				}
			});
		},
		getAddressList: function() {
			let that = this;
			getAddressList().then(res => {
				that.addressList = res.data[0];
			});
		},
		getVouchersAdd: function() {
			
			let params = {
				addressId: this.addressList.id,
				bargainId: '',
				combinationId: '',
				couponId: this.id,
				from: '',
				isChannel: '',
				mark: '',
				orderTag: 0,
				payType: 'duihuan',
				phone: '',
				pinkId: '0',
				plateCouponId: '',
				plateCouponPrice: 0,
				realName: '',
				seckillId: '',
				shippingType: '1',
				storeId: '',
				uniqueId: '',
				useIntegral: '',
				userCommission: 0
			};
			getVouchersAdd(params).then(res => {
				if(res.status == 200){
					this.$yrouter.push({ path: '/pages/order/OrderDetails/index' , query: { id: res.data.result.orderId }})
				}else{
					uni.showToast({
					  title:err.msg,
					  icon: "none",
					  duration: 2000
					});
				}
			});
		}
	}
};
</script>

<style lang="less">
.exchangeOrder-q {
	.exchangeOrder-w {
		margin-top: 24rpx;
		height: 110rpx;
		background: #ffffff;
		.exchangeOrder-e {
			display: flex;
			justify-content: space-between;
			.exchangeOrder-r {
				display: flex;
				.exchangeOrder-t {
					width: 26rpx;
					height: 28rpx;
					margin-top: 24rpx;
					margin-left: 24rpx;
					image {
						width: 100%;
						height: 100%;
					}
				}
				.exchangeOrder-y {
					font-size: 24rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #333333;
					line-height: 36rpx;
					margin-left: 16rpx;
					.exchangeOrder-u {
						margin-top: 24rpx;
					}
				}
			}
			.exchangeOrder-o {
				width: 20rpx;
				height: 35rpx;
				margin-top: 38rpx;
				margin-right: 24rpx;
				image {
					width: 100%;
					height: 100%;
				}
			}
		}
	}
	.exchangeOrder-p {
		height: 72rpx;
		margin-top: 24rpx;
		background: #ffffff;
		font-size: 24rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #333333;
		line-height: 72rpx;
		text {
			margin-left: 24rpx;
		}
	}
	.exchangeOrder-a {
		background: #ffffff;
		.exchangeOrder-s {
			width: 94%;
			margin: auto;
			padding: 20rpx;
			border-bottom: 1rpx solid #eee;
			.exchangeOrder-d {
				height: 110rpx;
				display: flex;
				justify-content: space-between;
				margin-bottom: 24rpx;
				.exchangeOrder-f {
					display: flex;
					.exchangeOrder-g {
						width: 110rpx;
						height: 100rpx;
						image {
							width: 100%;
							height: 100%;
						}
					}
					.exchangeOrder-h {
						margin-left: 12rpx;
						.exchangeOrder-j {
							font-size: 24rpx;
							font-family: Source Han Sans CN;
							font-weight: 500;
							color: #333333;
							line-height: 36rpx;
						}
						.exchangeOrder-k {
							font-size: 20rpx;
							font-family: Source Han Sans CN;
							font-weight: 400;
							color: #999999;
							line-height: 36rpx;
						}
						.exchangeOrder-l {
							font-size: 20rpx;
							font-family: Source Han Sans CN;
							font-weight: 400;
							color: #ff1a1a;
							line-height: 36rpx;
						}
					}
				}
				.exchangeOrder-z {
					font-size: 20rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #999999;
					line-height: 110rpx;
					margin-right: 24rpx;
				}
			}
		}
		.exchangeOrder-x {
			height: 71rpx;
			width: 94%;
			margin: auto;
			display: flex;
			justify-content: space-between;
			.exchangeOrder-c {
				font-size: 24rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #333333;
				line-height: 71rpx;
			}
			.exchangeOrder-v {
				font-size: 20rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #333333;
				line-height: 71rpx;
			}
		}
	}
	.exchangeOrder-b {
		width: 100%;
		position: fixed;
		bottom: 0;
		height: 98rpx;
		background: #ffffff;
		.exchangeOrder-n {
			width: 213rpx;
			height: 60rpx;
			background: #ff5e06;
			font-size: 24rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #fffefe;
			line-height: 60rpx;
			text-align: center;
			float: right;
			margin-top: 20rpx;
			margin-right: 24rpx;
		}
	}
}
</style>
